
import java.util.ArrayList;
import java.util.List;

class Department {
    private List<Instructor> instructors = new ArrayList<>();
    private List<Subject> subjects = new ArrayList<>();

    public void addInstructor(Instructor instructor) {
        instructors.add(instructor);
    }

    public void addSubject(Subject subject) {
        subjects.add(subject);
    }

    public List<Instructor> getInstructors() {
        return new ArrayList<>(instructors);
    }

    public List<Subject> getSubjects() {
        return new ArrayList<>(subjects);
    }
}

class Instructor {
    private Department department;
    private List<Subject> teaches = new ArrayList<>();

    public Instructor(Department department) {
        this.department = department;
    }

    public void addTeachingSubject(Subject subject) {
        teaches.add(subject);
    }

    public Department getDepartment() {
        return department;
    }

    public List<Subject> getTeaches() {
        return new ArrayList<>(teaches);
    }
}

class Subject {
    private String name;

    public Subject(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}

class Student {
    private List<Subject> enrolledCourses = new ArrayList<>();

    public void enrollInCourse(Subject subject) {
        enrolledCourses.add(subject);
    }

    public List<Subject> getEnrolledCourses() {
        return new ArrayList<>(enrolledCourses);
    }
}

public class School {
    private List<Department> departments = new ArrayList<>();
    private List<Student> students = new ArrayList<>();

    public void addDepartment(Department department) {
        departments.add(department);
    }

    public void addStudent(Student student) {
        students.add(student);
    }

    public List<Department> getDepartments() {
        return new ArrayList<>(departments);
    }

    public List<Student> getStudents() {
        return new ArrayList<>(students);
    }

    public static void main(String[] args) {
  
        Subject math = new Subject("Mathematics");
        Subject physics = new Subject("Physics");
        Subject chemistry = new Subject("Chemistry");

        Department scienceDept = new Department();
        scienceDept.addSubject(math);
        scienceDept.addSubject(physics);
        scienceDept.addSubject(chemistry);

        Instructor profSmith = new Instructor(scienceDept);
        profSmith.addTeachingSubject(math);
        profSmith.addTeachingSubject(physics);

        Student student = new Student();
        student.enrollInCourse(math);
        student.enrollInCourse(chemistry);
        student.enrollInCourse(physics);
        student.enrollInCourse(chemistry);
        
        School school = new School();
        school.addDepartment(scienceDept);
        school.addStudent(student);


        System.out.println("学校院系统计: " + school.getDepartments().size());
        System.out.println("科学系课程数: " + scienceDept.getSubjects().size());
        System.out.println("学生选课数: " + student.getEnrolledCourses().size());
    }
}
